\section{Include/FastNN.h File Reference}
\label{_fast_n_n_8h}\index{Include/FastNN.h@{Include/FastNN.h}}


This file contains the headers and struct declarations needed in the implementation of a fast evaluator for a neural network. This struct cannot be used for training the network, but provides an improvement in speed and memory usage for network evaluation.  


{\ttfamily \#include $<$cmath$>$}\par
{\ttfamily \#include $<$cstdlib$>$}\par
{\ttfamily \#include $<$cstring$>$}\par
{\ttfamily \#include \char`\"{}Options.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}NeuralNet.h\char`\"{}}\par
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct {\bf FastNN}
\end{DoxyCompactItemize}
\subsection*{Defines}
\begin{DoxyCompactItemize}
\item 
\#define {\bfseries FAST\_\-RAND\_\-MAX}~32767\label{_fast_n_n_8h_a7040ce2b63347533c054b3f46ef7a790}

\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void {\bf matrixVectorProduct} (double $\ast$A, double $\ast$x, double $\ast$b, int numRows, int numCols)
\item 
void {\bf fast\_\-srand} (int seed)
\item 
int {\bf fastrand} ()
\item 
void {\bf initializeFastNN} ({\bf FastNN} \&nn)
\item 
void {\bf sigmoid} (double $\ast$values, int num)
\item 
void {\bf setInputs} ({\bf FastNN} \&nn, double $\ast$inputVals)
\item 
void {\bf generateOutput} ({\bf FastNN} \&nn)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
This file contains the headers and struct declarations needed in the implementation of a fast evaluator for a neural network. This struct cannot be used for training the network, but provides an improvement in speed and memory usage for network evaluation. \begin{DoxyAuthor}{Author}
Thomas Fu $<${\tt thomas.ks.fu@gmail.com}$>$ 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
0.0.1 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
06/02/2011
\end{DoxyDate}
\subsection{License}\label{_i_o_data_types_8h_License}
This program is propety of Jyeah Jyeah Jyeah Jyeah Jyeah and may not be used by any individual for any purpose at any time without express permission from Mike Casey, Thomas Fu, Chris Hairfield, Kyle Lamson, Ben Treweek, or Cliff Warren. 

\subsection{Function Documentation}
\index{FastNN.h@{FastNN.h}!fast\_\-srand@{fast\_\-srand}}
\index{fast\_\-srand@{fast\_\-srand}!FastNN.h@{FastNN.h}}
\subsubsection[{fast\_\-srand}]{\setlength{\rightskip}{0pt plus 5cm}void fast\_\-srand (
\begin{DoxyParamCaption}
\item[{int}]{seed}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  [inline]}}\label{_fast_n_n_8h_a8caee38dd990c5a1d30deeae7cdc5a37}
Faster version of the built-\/in srand function taken from Intel's site {\tt http://software.intel.com/en-\/us/articles/fast-\/random-\/number-\/generator-\/on-\/the-\/intel-\/pentiumr-\/4-\/processor/}


\begin{DoxyParams}{Parameters}
{\em seed} & Seed number for the random number generator \\
\hline
\end{DoxyParams}
\index{FastNN.h@{FastNN.h}!fastrand@{fastrand}}
\index{fastrand@{fastrand}!FastNN.h@{FastNN.h}}
\subsubsection[{fastrand}]{\setlength{\rightskip}{0pt plus 5cm}int fastrand (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  [inline]}}\label{_fast_n_n_8h_aaa736d1481652daab2871fd675a7b09a}
Faster version of the built-\/in rand function taken from Intel's site {\tt http://software.intel.com/en-\/us/articles/fast-\/random-\/number-\/generator-\/on-\/the-\/intel-\/pentiumr-\/4-\/processor/}

\begin{DoxyReturn}{Returns}
Returns a single random integer in a range \char`\"{}similar\char`\"{} to that as cstdlib. 
\end{DoxyReturn}
\index{FastNN.h@{FastNN.h}!generateOutput@{generateOutput}}
\index{generateOutput@{generateOutput}!FastNN.h@{FastNN.h}}
\subsubsection[{generateOutput}]{\setlength{\rightskip}{0pt plus 5cm}void generateOutput (
\begin{DoxyParamCaption}
\item[{{\bf FastNN} \&}]{nn}
\end{DoxyParamCaption}
)}\label{_fast_n_n_8h_a3e1328d932c73bc860502a1a37c3fa3c}
Propagates the input values through the network and places the results of the network evaluation at nn.outputValues


\begin{DoxyParams}{Parameters}
{\em nn} & The \doxyref{FastNN}{p.}{struct_fast_n_n} to be used in the evaluation. \\
\hline
\end{DoxyParams}
\index{FastNN.h@{FastNN.h}!initializeFastNN@{initializeFastNN}}
\index{initializeFastNN@{initializeFastNN}!FastNN.h@{FastNN.h}}
\subsubsection[{initializeFastNN}]{\setlength{\rightskip}{0pt plus 5cm}void initializeFastNN (
\begin{DoxyParamCaption}
\item[{{\bf FastNN} \&}]{nn}
\end{DoxyParamCaption}
)}\label{_fast_n_n_8h_a954071aef77a97d71a69b220d4172bd0}
Allocates all memory associated with the \doxyref{FastNN}{p.}{struct_fast_n_n} struct based on the values of numInputs, numOutputs, and numHidden specified in the \doxyref{FastNN}{p.}{struct_fast_n_n} struct.


\begin{DoxyParams}{Parameters}
{\em nn} & A \doxyref{FastNN}{p.}{struct_fast_n_n} struct whose values of numInputs, numOutputs, and numHidden have been set accordingly. \\
\hline
\end{DoxyParams}
\index{FastNN.h@{FastNN.h}!matrixVectorProduct@{matrixVectorProduct}}
\index{matrixVectorProduct@{matrixVectorProduct}!FastNN.h@{FastNN.h}}
\subsubsection[{matrixVectorProduct}]{\setlength{\rightskip}{0pt plus 5cm}void matrixVectorProduct (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{A, }
\item[{double $\ast$}]{x, }
\item[{double $\ast$}]{b, }
\item[{int}]{numRows, }
\item[{int}]{numCols}
\end{DoxyParamCaption}
)}\label{_fast_n_n_8h_a944622464660949dceb7d86ebabc2b3a}
Computes the matrix-\/vector product for the matrix A (represented as a one dimensional array with elements in row major order) and the vector x and stores the result in the vector b.


\begin{DoxyParams}{Parameters}
{\em A} & A one dimensional array representation of a matrix (where the elements are presented in row major order).\\
\hline
{\em x} & A one dimensional array representation of a column vector\\
\hline
{\em b} & A one dimensional array representation of the column vector result of the matrix multiplication A $\ast$ x = b. Space for this vector should be allocated prior to the calling of this function\\
\hline
{\em numRows} & The number of rows in the matrix represented by A\\
\hline
{\em numCols} & The number of columns in the matrix represented by B \\
\hline
\end{DoxyParams}
\index{FastNN.h@{FastNN.h}!setInputs@{setInputs}}
\index{setInputs@{setInputs}!FastNN.h@{FastNN.h}}
\subsubsection[{setInputs}]{\setlength{\rightskip}{0pt plus 5cm}void setInputs (
\begin{DoxyParamCaption}
\item[{{\bf FastNN} \&}]{nn, }
\item[{double $\ast$}]{inputVals}
\end{DoxyParamCaption}
)}\label{_fast_n_n_8h_a7547694902b8fe8a57e12bdafd0c4edf}
Sets the input values to the neural network prior to evaluation


\begin{DoxyParams}{Parameters}
{\em nn} & The \doxyref{FastNN}{p.}{struct_fast_n_n} to be used in the evaluation.\\
\hline
{\em inputVals} & An array of values to be used at the inputs to the network. This array should hold a number of elements equal to nn.numInputs \\
\hline
\end{DoxyParams}
\index{FastNN.h@{FastNN.h}!sigmoid@{sigmoid}}
\index{sigmoid@{sigmoid}!FastNN.h@{FastNN.h}}
\subsubsection[{sigmoid}]{\setlength{\rightskip}{0pt plus 5cm}void sigmoid (
\begin{DoxyParamCaption}
\item[{double $\ast$}]{values, }
\item[{int}]{num}
\end{DoxyParamCaption}
)}\label{_fast_n_n_8h_acd4ec4ad424a02d52c6395774bd7c6f8}
Maps each value stored in values to a real number between 0 and 1 via a sigmoid function.


\begin{DoxyParams}{Parameters}
{\em values} & The list of values to have the sigmoid function applied to them. These values will be overwritten in the course of this operation.\\
\hline
{\em num} & The number of elements contained in values \\
\hline
\end{DoxyParams}
